<?php

namespace App\Admin\Forms\Tenant;

use App\Wen\Utils\FieldUtils;
use App\Wen\Utils\Settings;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;

class PayModelCodeForm4 extends Form implements LazyRenderable
{
    use LazyWidget;

    public function handle(array $input)
    {
        for ($i = 31; $i <= 40; $i++){
            if(isset($input['mini_pay_code_'.$i])){
                Settings::set('mini_pay_code_'.$i, $input['mini_pay_code_'.$i], true);
            }
        }

        return $this->response()
            ->success('配置成功')
            ->refresh();
    }

    public function form()
    {
        $this->html(function () {
            return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">付费31：多商户</div>';
        }, '');
        $this->image('mini_pay_code_31', '付费31')->help('<a href="https://img.mini.minisns.cn/2024/03/02/0/5071fc26ab0e7e31aeef59e35196c663.png" target="_blank">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('mini_pay_code_31', 'https://img.mini.minisns.cn/2024/03/02/0/5071fc26ab0e7e31aeef59e35196c663.png'));
        $this->html(function () {
            return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">付费32：群推送</div>';
        }, '');
        $this->image('mini_pay_code_32', '付费32')->help('<a href="https://img.mini.minisns.cn/2024/04/05/0/8ece49e0ff75217fe6a33459d48067b2.png" target="_blank">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('mini_pay_code_32', 'https://img.mini.minisns.cn/2024/04/05/0/8ece49e0ff75217fe6a33459d48067b2.png'));
        $this->html(function () {
            return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">付费33：选票活动</div>';
        }, '');
        $this->image('mini_pay_code_33', '付费33')->help('<a href="https://img.mini.minisns.cn/2024/04/21/0/5532bab95b8051dfa9a82043d67fadbd.png" target="_blank">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('mini_pay_code_33', 'https://img.mini.minisns.cn/2024/04/21/0/5532bab95b8051dfa9a82043d67fadbd.png'));
        $this->html(function () {
            return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">付费34：公众号自动推文</div>';
        }, '');
        $this->image('mini_pay_code_34', '付费34')->help('<a href="https://img.mini.minisns.cn/2024/05/28/0/43aab398869588ecfd810a537578c4da.png" target="_blank">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('mini_pay_code_34', 'https://img.mini.minisns.cn/2024/05/28/0/43aab398869588ecfd810a537578c4da.png'));
    }
}
